export function formValidation(data){
    /*  参数格式
    1.数组：[{checkType:'required', checkVal: ''},{checkType:'phone', checkVal: ''}]
    2.对象：{checkType:'number', checkVal: ''} 
     */
    if(data instanceof(Array)){
        for(let elem of data){
            if(!formValidation(elem)){
                return false
            }
        }
        return true;
    }
    else{
        if(data.checkVal===null || data.checkVal===undefined)
            return false;
        switch(data.checkType){
            case 'number': return /^\d+$/.test(data.checkVal);
            case 'phone': return /^1\d{10}$/.test(data.checkVal);
            case 'required': return /\S+/.test(data.checkVal);
            case 'requiredArray': return (data.checkVal instanceof(Array) && data.checkVal.length>0)
            default: return true;
        }
    }
}